<template>
	<view class="rh-switch-container">
		<view class="switch-item">
			<view class="switch-label">
				<slot name="label-icon"></slot>
				<text class="label-txt">{{label}}</text>
			</view>
			<view class="switch-content">
				<u-switch :disabled="disabled" size="36" active-color="#22984E" v-model="emitValue" @change="change"></u-switch>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			label: String,
			value: [Boolean],
			disabled: {
				type: Boolean,
				default: () => {return false}
			}
		},
		watch: {
			value(val){
				this.emitValue = val
			},
		},
		data() {
			return {
				emitValue: this.value
			};
		},
		methods: {
			change(boo){
				let _self = this
				console.log(boo, 565656)
				_self.$emit('input', boo)
				_self.$emit('change', boo)
			},
		}
	}
</script>

<style scoped lang="scss">
	.rh-switch-container{
		width: 100%;
	}
	.switch-item{
		display: flex;
		justify-content: space-between;
		align-items: center;
		.switch-label{
			display: flex;
			align-items: center;
			.label-txt{
				font-size: 26rpx;
				color: #666;
			}
		}
		.switch-content{
			display: flex;
			align-items: center;
		}
	}
</style>
